<?php

namespace App\Admin\Controllers;

use App\Courses;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class CourseController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = 'Courses';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new Courses());

        $grid->column('id', __('Id'));
        $grid->column('name', __('Name'));
        $grid->column('speaker_id', __('Speaker id'));
        $grid->column('creator_id', __('Creator id'));
        $grid->column('course_date', __('Course date'));
        $grid->column('start_time', __('Start time'));
        $grid->column('end_time', __('End time'));
        $grid->column('record_state', __('Record state'));
        $grid->column('class_id', __('Class id'));
        $grid->column('phase_id', __('Phase id'));
        $grid->column('grade_id', __('Grade id'));
        $grid->column('subject_id', __('Subject id'));
        $grid->column('section_index', __('Section index'));
        $grid->column('video_id', __('Video id'));
        $grid->column('school_id', __('School id'));
        $grid->column('type', __('Type'));
        $grid->column('cover_url', __('Cover url'));
        $grid->column('deleted_at', __('Deleted at'));
        $grid->column('created_at', __('Created at'));
        $grid->column('updated_at', __('Updated at'));

        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(Courses::findOrFail($id));

        $show->field('id', __('Id'));
        $show->field('name', __('Name'));
        $show->field('speaker_id', __('Speaker id'));
        $show->field('creator_id', __('Creator id'));
        $show->field('course_date', __('Course date'));
        $show->field('start_time', __('Start time'));
        $show->field('end_time', __('End time'));
        $show->field('record_state', __('Record state'));
        $show->field('class_id', __('Class id'));
        $show->field('phase_id', __('Phase id'));
        $show->field('grade_id', __('Grade id'));
        $show->field('subject_id', __('Subject id'));
        $show->field('section_index', __('Section index'));
        $show->field('video_id', __('Video id'));
        $show->field('school_id', __('School id'));
        $show->field('type', __('Type'));
        $show->field('cover_url', __('Cover url'));
        $show->field('deleted_at', __('Deleted at'));
        $show->field('created_at', __('Created at'));
        $show->field('updated_at', __('Updated at'));

        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new Courses());

        $form->text('name', __('Name'));
        $form->number('speaker_id', __('Speaker id'));
        $form->number('creator_id', __('Creator id'));
        $form->date('course_date', __('Course date'))->default(date('Y-m-d'));
        $form->text('start_time', __('Start time'));
        $form->text('end_time', __('End time'));
        $form->switch('record_state', __('Record state'));
        $form->number('class_id', __('Class id'));
        $form->number('phase_id', __('Phase id'));
        $form->number('grade_id', __('Grade id'));
        $form->number('subject_id', __('Subject id'));
        $form->text('section_index', __('Section index'));
        $form->number('video_id', __('Video id'));
        $form->number('school_id', __('School id'));
        $form->switch('type', __('Type'))->default(1);
        $form->text('cover_url', __('Cover url'));

        return $form;
    }
}
